<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>异常订单</title>
    <!--{include file='comm/comm_cal.tpl'}-->
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->

   
    <div class="comm_crub">
        <span class="now_crub">异常订单</span>
    </div>

    <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form id="search_form" onsubmit="return false;">
                        <table>
                            <tbody>
                            <tr>
                                <td>
                                    <span>订单号：<input type="text" value="" size="18" name="bill_no" class="clear_search" /></span>
                                    <span>包裹号：<input type="text" value="" size="6" name="package_no" class="clear_search" /></span>
                                    <span>
                                        订单来源：<select class="clear_search" style="width: 106px;" id="billType" name="billType">
                                            <option value="">请选择</option>
                                            <option value="1">B2C商城</option>
                                            <option value="2">天猫商城</option>
                                            <option value="3">京东商城</option>
                                            <option value="4">1号店</option>
                                            <option value="5">QQ网购</option>
                                            <option value="6">凡客</option>
                                            <option value="7">苏宁易购</option>
                                            <option value="8">实体店</option>
                                            <option value="9">补货单</option>
                                            <option value="10">换货单</option>
                                        </select>
                                    </span>
                                    <span>
                                        异常类型：<select  style="width: 106px;" name="exception_type" id="exception_type"  >
                                            <option value="-1">请选择</option>
                                            <option value="1">仓库踢回</option>
                                            <option value="2">物流异常</option>
                                        </select>
                                    </span>
                                    <span>
                                        处理状态：<select  style="width: 90px;" name="handle_status" id="handle_status"  >
                                            <option value="-1">请选择</option>
                                            <option value="0">未处理</option>
                                            <option value="1">已处理</option>
                                        </select>
                                    </span>
                                    <span>
                                        生成时间：
                                        <input id="startDate" class="clear_search" size="7" name="startDate" value="" readonly="readonly" type="text">
                                        ～
                                        <input id="endDate" class="clear_search" size="7" name="endDate" value="" readonly="readonly" type="text">
                                    </span>
                                    <span><input type="button" value="查询" class="btn" onclick="bill.search();" /></span>
                                    <span><input type="button" value="重置" class="btn" onclick="bill.clear();" /></span>

                                </td>
                            </tr>

                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>

    

</div>

<script type="text/javascript">

    $("#flex").flexigrid({
        url:"/invokingAjax-backend/bill/billException.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            {display: "操作", width : 150, align: "center"},
            {display: "处理状态", width : 50, align: "center"},
            {display: "订单号", name : "bill_no", align : "center" , width : 150, sortable : true},
            {display: "订单来源", width : 100},
            {display: "生成时间", align : "center" , width : 150},
            {display: "异常类型", width : 80},
            {display: "异常原因", width : 310},
            {display: "异常发出人", width : 80},
            {display: "批次号", width : 150},
            {display: "包裹号", width : 100},
            {display: "处理人", width : 80},
            {display: "处理时间", align : "center" ,width : 150},
            {display: "处理备注", width : 200}
        ],
        sortname: "createTime",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        autoload: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var bill = {

        search: function() {
            var dt = $("#search_form").serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        clear : function (){
            $(".clear_search").val('');
            $("#exception_type").val("-1");
            $("#handle_status").val("-1");
            $("#billType").val("");
        },

        view: function( bill_no ) {
            E.open("/quanliadmin/app/bill/bill.pscript?operFlg=2&bill_no=" + bill_no, "", {height: 600, width: 1024, top: 10, left: 100});
        },

        result: function( o ) {
            if (o.code == 200) {
                E.alert(o.message, 2);
                bill.search();
            } else {
                E.alert(o.message);
            }
        },

        cancel: function( id , bill_no) {
            this.id = id;
            this.bill_no = bill_no;

            var h = "<table>";
            h += "<tbody>"
            h += "<tr>"
            h += "<td>"
            h += "您确认取消该订单吗？"
            h += "</td>"
            h += "</tr>"
            h += "<tr>"
            h += "<td>"
            h += "请输入异常处理备注："
            h += "</td>"
            h += "</tr>"
            h += "<tr>"
            h += "<td>";
            h += "<textarea id='handler_remark'></textarea>";
            h += "</td>";
            h += "</tr>"
            h += "</tbody>"
            h += "</table>"

            E.popup.open({
                title: "订单取消",
                content: h,    //显示内容（html代码），不传则默认为空【可选】
                btnName: "确认", //“确认”按钮，不传则不显示
                btnCall: "bill.confirmCancel();"
            });
            $(".popup-main").css("width" , 450);
        },

        confirmCancel: function() {

            var remark = $.trim($("#handler_remark").val());
            if(remark == ''){
                E.alert("请填写异常处理备注");
                return;
            }

            E.ajax_post({
                url: "/invokingAjax-backend/bill/billException.ajax?operFlg=2",
                data: {
                    id: this.id,
                    bill_no : this.bill_no,
                    remark : remark
                },
                call: "bill.result"
            });

            E.popup.close();

        },

        delivery: function( id , bill_no ) {
            this.id = id;
            this.bill_no = bill_no;

            var h = "<table>";
            h += "<tbody>"
            h += "<tr>"
            h += "<td>"
            h += "您确认该订单重新发货吗？"
            h += "</td>"
            h += "</tr>"
            h += "<tr>"
            h += "<td>"
            h += "请输入异常处理备注："
            h += "</td>"
            h += "</tr>"
            h += "<tr>"
            h += "<td>";
            h += "<textarea id='handler_remark'></textarea>";
            h += "</td>";
            h += "</tr>"
            h += "</tbody>"
            h += "</table>"

            E.popup.open({
                title: "订单重新发货",
                content: h,
                btnName: "确认",
                btnCall: "bill.deliveryCancel();"
            });
            $(".popup-main").css("width" , 450);
        },

        deliveryCancel: function() {

            var remark = $.trim($("#handler_remark").val());
            if(remark == ''){
                E.alert("请填写异常处理备注");
                return;
            }

            E.ajax_post({
                url: "/invokingAjax-backend/bill/billException.ajax?operFlg=3",
                data: {
                    id: this.id,
                    bill_no : this.bill_no,
                    remark : remark
                },
                call: "bill.result"
            });


            E.popup.close();
        },

        alter: function( bill_no ) {
            E.open("/quanliadmin/app/bill/bill.pscript?operFlg=3&bill_no=" + bill_no, "", {height: 600, width: 1024, top: 10, left: 100});
        }

    };

    cal.manageFields("startDate", "startDate", "%Y-%m-%d");
    cal.manageFields("endDate", "endDate", "%Y-%m-%d");

</script>

</body>
</html>